package cn.edu.jcu.kyle.gintama;

import cn.edu.jcu.kyle.gintama.OurUtil.BilibiliVideo;
import cn.edu.jcu.kyle.gintama.OurUtil.COVIDQuery;
import cn.edu.jcu.kyle.gintama.OurUtil.PhoneQuery;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.Node;
import javafx.scene.control.ChoiceBox;
import javafx.scene.control.TextField;

public class HelloController {
    @FXML
    public TextField input;         //输入框的文本
    public ChoiceBox<String> choicebox;     //选择列表
    public TextField userName;
    public TextField userPassword;

    @FXML
    protected void justaButton() {
        if ("新冠疫情查询".equals(choicebox.getValue())) {
            System.out.println("wx");
            COVIDQuery.Query(input.getText());
        } else if ("电话号码查询".equals(choicebox.getValue())) {
            System.out.println("pjj");
            PhoneQuery.Query(input.getText());
        } else if ("哔哩哔哩视频解析".equals(choicebox.getValue())) {
            System.out.println("lmq");
            BilibiliVideo.Query(input.getText());
        }
    }

    @FXML
    public void login(ActionEvent actionEvent) {    //连接数据库
        if (DbUtil.dbInit(userName.getText(), userPassword.getText())) {
            ((Node) (actionEvent.getSource())).getScene().getWindow().hide();
            //AlertWindow.getWindow("连接数据库成功！");
            try {
                HelloApplication.funcView();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
}